<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" th:with="title='新增角色'">
<meta charset="utf-8">
<header th:replace="header::headerFragment(${title})"></header>
<body class="gray-bg">
	<div class="wrapper wrapper-content ">
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-content">
						<form class="form-horizontal m-t" id="RoleForm">
							<div class="form-group">
								<label class="col-sm-3 control-label">角色名称：</label>
								<div class="col-sm-8">
									<input id="roleName" name="roleName" class="form-control" type="text">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">角色标识：</label>
								<div class="col-sm-8">
									<input id="roleSign" name="roleSign" class="form-control" type="text">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">备注：</label>
								<div class="col-sm-8">
									<input id="remark" name="remark" class="form-control" type="text">
								</div>
							</div>
							<div class="form-group">
								<div class="col-sm-8 col-sm-offset-3">
									<button type="submit" class="btn btn-primary">提交</button>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div th:replace="footer :: footer"></div>
	<script type="text/javascript">
	var prefix = ctx + "sys/role";
		$().ready(function() {
	        validateRule();
        });
        $.validator.setDefaults({
	        submitHandler : function() {
		        save();
	        }
        });
        function save() {
	        yimo.ajaxPost({
	            url : prefix + "/save",
	            data : $('#RoleForm').serialize(),
	            needClose : true,
	            parentRefresh : true,
	        });
        }

        function validateRule() {
	        var icon = "<i class='fa fa-times-circle'></i> ";
	        $("#RoleForm").validate({
	            rules : {
	                roleName : {
		                required : true
	                },
	                roleSign : {
		                required : true
	                },
	                status : {
		                required : true
	                },
	            },
	            messages : {
	                roleName : {
		                required : icon + "请输入角色名称"
	                },
	                roleSign : {
		                required : icon + "请输入角色标识"
	                },
	                remark : {
		                required : icon + "请输入备注"
	                },
	                createUserId : {
		                required : icon + "请输入创建用户id"
	                },
	                createTime : {
		                required : icon + "请输入创建时间"
	                },
	                updateTime : {
		                required : icon + "请输入更新时间"
	                },
	                status : {
		                required : icon + "请输入角色状态"
	                },
	            }
	        })
        }
	</script>
</body>
</html>
